package com.bridgetree.jubaocrm.ui.project;

import java.util.HashMap;
import java.util.List;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.bridgetree.jubaocrm.R;

/**
 * 项目的设配器
 * @author Administrator
 *
 */
public class XMAdapter extends BaseAdapter {
		private List<HashMap<String, Object>> Date = null;
		private Context context;
		private LayoutInflater mInflater;
		public HashMap<Integer, Bitmap> cachedBitmap;

		private class GridHolder {
			TextView tv;
		}

		@SuppressLint("UseSparseArrays")
		public XMAdapter(Context c,List<HashMap<String, Object>> proInfoListData) {
			super();
			this.context = c;
			this.Date=proInfoListData;
			mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		}

		public int getCount() {
			return Date.size();
		}

		@Override
		public Object getItem(int index) {
			return Date.get(index);
		}

		@Override
		public long getItemId(int index) {
			return index;
		}

		@Override
		public View getView(final int index, View convertView, ViewGroup parent) {
			GridHolder holder;
			if (convertView == null) {
				convertView = mInflater.inflate(R.layout.xm_12_item, null);
				holder = new GridHolder();
				holder.tv = (TextView) convertView.findViewById(R.id.xm_12_item_tv);
				convertView.setTag(holder);
			} else {
				holder = (GridHolder) convertView.getTag();
			}
			
			final String xm_txt=Date.get(index).get("tv").toString();
			holder.tv.setText(xm_txt);
			convertView.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View v) {
					Intent intent = new Intent(context, XMChildActivity.class);
					Bundle bundle = new Bundle();
					bundle.putString("xm_title", xm_txt);
					intent.putExtras(bundle);
					context.startActivity(intent);
				}
			});
			return convertView;
		}
	}

